﻿using System;
using System.Collections;
using Manager;
using Studio;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x02000525 RID: 1317
public class StudioScene : BaseLoader
{
	// Token: 0x06002181 RID: 8577 RVA: 0x000CCB9C File Offset: 0x000CAD9C
	public void OnClickDraw(int _no)
	{
		Singleton<Studio.Studio>.Instance.workInfo.visibleFlags[_no] = !Singleton<Studio.Studio>.Instance.workInfo.visibleFlags[_no];
		SortCanvas.select = this.drawInfo.canvasSystemMenu;
		this.UpdateUI(_no);
	}

	// Token: 0x06002182 RID: 8578 RVA: 0x000CCBDC File Offset: 0x000CADDC
	private void UpdateUI(int _no)
	{
		bool flag = Singleton<Studio.Studio>.Instance.workInfo.visibleFlags[_no];
		switch (_no)
		{
		case 0:
			this.drawInfo.canvasMainMenu.enabled = flag;
			this.drawInfo.systemButtonCtrl.visible = flag;
			this.drawInfo.imageMenu.sprite = this.drawInfo.spriteMenu[(!flag) ? 1 : 0];
			break;
		case 1:
			this.drawInfo.canvasList.enabled = flag;
			this.drawInfo.imageWork.sprite = this.drawInfo.spriteWork[(!flag) ? 1 : 0];
			break;
		case 2:
			Singleton<GuideObjectManager>.Instance.guideInput.outsideVisible = flag;
			this.drawInfo.imageMove.sprite = this.drawInfo.spriteMove[(!flag) ? 1 : 0];
			break;
		case 3:
			Singleton<Studio.Studio>.Instance.colorPaletteCtrl.outsideVisible = flag;
			this.drawInfo.imageColor.sprite = this.drawInfo.spriteColor[(!flag) ? 1 : 0];
			break;
		case 4:
			this.drawInfo.objOption.SetActive(flag);
			this.drawInfo.imageOption.sprite = this.drawInfo.spriteOption[(!flag) ? 1 : 0];
			break;
		case 5:
			this.drawInfo.objCamera.SetActive(flag);
			this.drawInfo.imageCamera.sprite = this.drawInfo.spriteCamera[(!flag) ? 1 : 0];
			break;
		}
	}

	// Token: 0x06002183 RID: 8579 RVA: 0x000CCDA8 File Offset: 0x000CAFA8
	private void UpdateUI()
	{
		for (int i = 0; i < 6; i++)
		{
			this.UpdateUI(i);
		}
		this.cameraInfo.center = Singleton<Studio.Studio>.Instance.workInfo.visibleCenter;
		this.cameraInfo.axis = Singleton<Studio.Studio>.Instance.workInfo.visibleAxis;
		this.cameraInfo.imageCamera.sprite = this.cameraInfo.spriteCamera[(!Singleton<Studio.Studio>.Instance.workInfo.useAlt) ? 0 : 1];
		this.mapInfo.Update();
	}

	// Token: 0x06002184 RID: 8580 RVA: 0x000CCE44 File Offset: 0x000CB044
	public void OnClickMode(int _mode)
	{
		SortCanvas.select = this.modeInfo.canvasInput;
		Singleton<GuideObjectManager>.Instance.mode = _mode;
	}

	// Token: 0x06002185 RID: 8581 RVA: 0x000CCE64 File Offset: 0x000CB064
	private void Instance_ModeChangeEvent(object sender, EventArgs e)
	{
		int mode = Singleton<GuideObjectManager>.Instance.mode;
		this.modeInfo.imageMode[0].sprite = this.modeInfo.spriteModeMove[(mode != 0) ? 0 : 1];
		this.modeInfo.imageMode[1].sprite = this.modeInfo.spriteModeRotate[(mode != 1) ? 0 : 1];
		this.modeInfo.imageMode[2].sprite = this.modeInfo.spriteModeScale[(mode != 2) ? 0 : 1];
	}

	// Token: 0x06002186 RID: 8582 RVA: 0x000CCF00 File Offset: 0x000CB100
	private bool NoCtrlCondition()
	{
		bool flag = Singleton<Studio.Studio>.IsInstance() && Singleton<Studio.Studio>.Instance.workInfo.useAlt;
		return flag && (!Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt));
	}

	// Token: 0x06002187 RID: 8583 RVA: 0x000CCF58 File Offset: 0x000CB158
	private bool KeyCondition()
	{
		return !Singleton<Studio.Studio>.IsInstance() || !Singleton<Studio.Studio>.Instance.isInputNow;
	}

	// Token: 0x06002188 RID: 8584 RVA: 0x000CCF78 File Offset: 0x000CB178
	public void OnClickCamera()
	{
		bool flag = !Singleton<Studio.Studio>.Instance.workInfo.useAlt;
		Singleton<Studio.Studio>.Instance.workInfo.useAlt = flag;
		this.cameraInfo.imageCamera.sprite = this.cameraInfo.spriteCamera[(!flag) ? 0 : 1];
	}

	// Token: 0x06002189 RID: 8585 RVA: 0x000CCFD4 File Offset: 0x000CB1D4
	public void OnClickSaveCamera(int _no)
	{
		Singleton<Studio.Studio>.Instance.sceneInfo.cameraData[_no] = this.cameraInfo.cameraCtrl.Export();
	}

	// Token: 0x0600218A RID: 8586 RVA: 0x000CCFF8 File Offset: 0x000CB1F8
	public void OnClickLoadCamera(int _no)
	{
		this.cameraInfo.cameraCtrl.Import(Singleton<Studio.Studio>.Instance.sceneInfo.cameraData[_no]);
	}

	// Token: 0x0600218B RID: 8587 RVA: 0x000CD01C File Offset: 0x000CB21C
	public void OnClickCenter()
	{
		bool flag = !Singleton<Studio.Studio>.Instance.workInfo.visibleCenter;
		Singleton<Studio.Studio>.Instance.workInfo.visibleCenter = flag;
		this.cameraInfo.center = flag;
	}

	// Token: 0x0600218C RID: 8588 RVA: 0x000CD058 File Offset: 0x000CB258
	public void OnClickAxis()
	{
		bool flag = !Singleton<Studio.Studio>.Instance.workInfo.visibleAxis;
		Singleton<Studio.Studio>.Instance.workInfo.visibleAxis = flag;
		this.cameraInfo.axis = flag;
	}

	// Token: 0x0600218D RID: 8589 RVA: 0x000CD094 File Offset: 0x000CB294
	public void OnClickTarget()
	{
	}

	// Token: 0x0600218E RID: 8590 RVA: 0x000CD098 File Offset: 0x000CB298
	public void OnClickUndo()
	{
		Singleton<UndoRedoManager>.Instance.Undo();
	}

	// Token: 0x0600218F RID: 8591 RVA: 0x000CD0A4 File Offset: 0x000CB2A4
	public void OnClickRedo()
	{
		Singleton<UndoRedoManager>.Instance.Redo();
	}

	// Token: 0x06002190 RID: 8592 RVA: 0x000CD0B0 File Offset: 0x000CB2B0
	private void Instance_CanUndoChange(object sender, EventArgs e)
	{
		this.buttonUndo.interactable = Singleton<UndoRedoManager>.Instance.CanUndo;
	}

	// Token: 0x06002191 RID: 8593 RVA: 0x000CD0C8 File Offset: 0x000CB2C8
	private void Instance_CanRedoChange(object sender, EventArgs e)
	{
		this.buttonRedo.interactable = Singleton<UndoRedoManager>.Instance.CanRedo;
	}

	// Token: 0x06002192 RID: 8594 RVA: 0x000CD0E0 File Offset: 0x000CB2E0
	private void ChangeScale()
	{
		float num = Input.GetAxis("Mouse X") * 0.1f;
		Studio.Studio.optionSystem.manipulateSize = Mathf.Clamp(Studio.Studio.optionSystem.manipulateSize + num, 0.1f, 2f);
		Singleton<GuideObjectManager>.Instance.SetScale();
		this.optionCtrl.UpdateUIManipulateSize();
	}

	// Token: 0x06002193 RID: 8595 RVA: 0x000CD138 File Offset: 0x000CB338
	public void OnClickMap()
	{
		this.mapInfo.active = !this.mapInfo.active;
	}

	// Token: 0x06002194 RID: 8596 RVA: 0x000CD154 File Offset: 0x000CB354
	protected override void Awake()
	{
		base.Awake();
		if (Singleton<StudioVR>.IsInstance())
		{
			Singleton<StudioVR>.Instance.active = false;
		}
	}

	// Token: 0x06002195 RID: 8597 RVA: 0x000CD174 File Offset: 0x000CB374
	private IEnumerator Start()
	{
		this.textAdjustment.font.material.mainTexture.filterMode = FilterMode.Point;
		if (!Singleton<Info>.Instance.isLoadList)
		{
			Singleton<Studio.Scene>.Instance.Load(new Studio.Scene.Data
			{
				sceneName = "StudioWait",
				isAdd = true,
				isLoading = false,
				isAsync = false,
				isFade = false,
				isOverlap = false
			});
			yield return Singleton<Info>.Instance.LoadExcelDataCoroutine();
			Singleton<Studio.Scene>.Instance.UnLoad();
		}
		this.cameraInfo.Init();
		CameraControl cameraCtrl = this.cameraInfo.cameraCtrl;
		cameraCtrl.noCtrlCondition = (CameraControl.NoCtrlFunc)Delegate.Combine(cameraCtrl.noCtrlCondition, new CameraControl.NoCtrlFunc(this.NoCtrlCondition));
		CameraControl cameraCtrl2 = this.cameraInfo.cameraCtrl;
		cameraCtrl2.keyCondition = (CameraControl.NoCtrlFunc)Delegate.Combine(cameraCtrl2.keyCondition, new CameraControl.NoCtrlFunc(this.KeyCondition));
		Singleton<GuideObjectManager>.Instance.ModeChangeEvent += this.Instance_ModeChangeEvent;
		this.Instance_ModeChangeEvent(null, null);
		Singleton<UndoRedoManager>.Instance.CanRedoChange += this.Instance_CanRedoChange;
		Singleton<UndoRedoManager>.Instance.CanUndoChange += this.Instance_CanUndoChange;
		this.buttonUndo.interactable = false;
		this.buttonRedo.interactable = false;
		Studio.Studio instance = Singleton<Studio.Studio>.Instance;
		instance.onChangeMap = (Action)Delegate.Combine(instance.onChangeMap, new Action(this.mapInfo.OnChangeMap));
		Singleton<Studio.Studio>.Instance.isInputNow = false;
		Camera.main.backgroundColor = Studio.Studio.optionSystem.backColor;
		Singleton<Manager.Sound>.Instance.Listener = Camera.main.transform;
		this.UpdateUI();
		(from _ in this.UpdateAsObservable()
		where !this.cameraInfo.cameraCtrl.isControlNow
		where Input.GetKey(KeyCode.B) && Input.GetMouseButton(1)
		select _).Subscribe(delegate(Unit _)
		{
			this.ChangeScale();
		}).AddTo(this);
		yield break;
	}

	// Token: 0x040022E3 RID: 8931
	[SerializeField]
	private StudioScene.DrawInfo drawInfo = new StudioScene.DrawInfo();

	// Token: 0x040022E4 RID: 8932
	[SerializeField]
	private StudioScene.ModeInfo modeInfo = new StudioScene.ModeInfo();

	// Token: 0x040022E5 RID: 8933
	public StudioScene.CameraInfo cameraInfo = new StudioScene.CameraInfo();

	// Token: 0x040022E6 RID: 8934
	[SerializeField]
	private Button buttonUndo;

	// Token: 0x040022E7 RID: 8935
	[SerializeField]
	private Button buttonRedo;

	// Token: 0x040022E8 RID: 8936
	[SerializeField]
	private StudioScene.MapInfo mapInfo = new StudioScene.MapInfo();

	// Token: 0x040022E9 RID: 8937
	[SerializeField]
	private Text textAdjustment;

	// Token: 0x040022EA RID: 8938
	[SerializeField]
	private OptionCtrl optionCtrl;

	// Token: 0x02000526 RID: 1318
	[Serializable]
	private class DrawInfo
	{
		// Token: 0x040022EB RID: 8939
		public Canvas canvasMainMenu;

		// Token: 0x040022EC RID: 8940
		public SystemButtonCtrl systemButtonCtrl;

		// Token: 0x040022ED RID: 8941
		public Canvas canvasList;

		// Token: 0x040022EE RID: 8942
		public Canvas canvasColor;

		// Token: 0x040022EF RID: 8943
		public GameObject objOption;

		// Token: 0x040022F0 RID: 8944
		public GameObject objCamera;

		// Token: 0x040022F1 RID: 8945
		public Image imageMenu;

		// Token: 0x040022F2 RID: 8946
		public Sprite[] spriteMenu;

		// Token: 0x040022F3 RID: 8947
		public Image imageWork;

		// Token: 0x040022F4 RID: 8948
		public Sprite[] spriteWork;

		// Token: 0x040022F5 RID: 8949
		public Image imageMove;

		// Token: 0x040022F6 RID: 8950
		public Sprite[] spriteMove;

		// Token: 0x040022F7 RID: 8951
		public Image imageColor;

		// Token: 0x040022F8 RID: 8952
		public Sprite[] spriteColor;

		// Token: 0x040022F9 RID: 8953
		public Image imageOption;

		// Token: 0x040022FA RID: 8954
		public Sprite[] spriteOption;

		// Token: 0x040022FB RID: 8955
		public Image imageCamera;

		// Token: 0x040022FC RID: 8956
		public Sprite[] spriteCamera;

		// Token: 0x040022FD RID: 8957
		public Canvas canvasSystemMenu;
	}

	// Token: 0x02000527 RID: 1319
	[Serializable]
	private class ModeInfo
	{
		// Token: 0x040022FE RID: 8958
		public Image[] imageMode;

		// Token: 0x040022FF RID: 8959
		public Sprite[] spriteModeMove;

		// Token: 0x04002300 RID: 8960
		public Sprite[] spriteModeRotate;

		// Token: 0x04002301 RID: 8961
		public Sprite[] spriteModeScale;

		// Token: 0x04002302 RID: 8962
		public Canvas canvasInput;
	}

	// Token: 0x02000528 RID: 1320
	[Serializable]
	public class CameraInfo
	{
		// Token: 0x170003F8 RID: 1016
		// (get) Token: 0x06002199 RID: 8601 RVA: 0x000CD1A8 File Offset: 0x000CB3A8
		// (set) Token: 0x0600219A RID: 8602 RVA: 0x000CD1B8 File Offset: 0x000CB3B8
		public bool center
		{
			get
			{
				return this.cameraCtrl.isOutsideTargetTex;
			}
			set
			{
				if (this.cameraCtrl.isOutsideTargetTex != value)
				{
					this.cameraCtrl.isOutsideTargetTex = value;
					this.imageCenter.color = ((!this.cameraCtrl.isOutsideTargetTex) ? Color.white : Color.green);
				}
			}
		}

		// Token: 0x170003F9 RID: 1017
		// (get) Token: 0x0600219B RID: 8603 RVA: 0x000CD20C File Offset: 0x000CB40C
		// (set) Token: 0x0600219C RID: 8604 RVA: 0x000CD21C File Offset: 0x000CB41C
		public bool axis
		{
			get
			{
				return this.cameraSub.enabled;
			}
			set
			{
				if (this.cameraSub.enabled != value)
				{
					this.cameraSub.enabled = value;
					this.physicsRaycaster.enabled = value;
					this.imageAxis.color = ((!value) ? Color.white : Color.green);
				}
			}
		}

		// Token: 0x0600219D RID: 8605 RVA: 0x000CD274 File Offset: 0x000CB474
		public void Init()
		{
			this.imageCenter.color = ((!this.cameraCtrl.isOutsideTargetTex) ? Color.white : Color.green);
			this.imageAxis.color = ((!this.cameraSub.enabled) ? Color.white : Color.green);
		}

		// Token: 0x04002303 RID: 8963
		public Image imageCamera;

		// Token: 0x04002304 RID: 8964
		public Sprite[] spriteCamera;

		// Token: 0x04002305 RID: 8965
		public CameraControl cameraCtrl;

		// Token: 0x04002306 RID: 8966
		public Image imageCenter;

		// Token: 0x04002307 RID: 8967
		public Image imageAxis;

		// Token: 0x04002308 RID: 8968
		public Camera cameraSub;

		// Token: 0x04002309 RID: 8969
		public PhysicsRaycaster physicsRaycaster;
	}

	// Token: 0x02000529 RID: 1321
	[Serializable]
	private class MapInfo
	{
		// Token: 0x170003FA RID: 1018
		// (get) Token: 0x0600219F RID: 8607 RVA: 0x000CD2E0 File Offset: 0x000CB4E0
		private Image image
		{
			get
			{
				if (this.m_Image == null)
				{
					this.m_Image = this.button.image;
				}
				return this.m_Image;
			}
		}

		// Token: 0x170003FB RID: 1019
		// (get) Token: 0x060021A0 RID: 8608 RVA: 0x000CD30C File Offset: 0x000CB50C
		// (set) Token: 0x060021A1 RID: 8609 RVA: 0x000CD314 File Offset: 0x000CB514
		public bool active
		{
			get
			{
				return this.m_Active;
			}
			set
			{
				this.m_Active = value;
				this.Update();
			}
		}

		// Token: 0x060021A2 RID: 8610 RVA: 0x000CD324 File Offset: 0x000CB524
		public void Update()
		{
			this.image.color = ((!this.m_Active) ? Color.white : Color.green);
			this.mapCtrl.active = this.m_Active;
		}

		// Token: 0x060021A3 RID: 8611 RVA: 0x000CD35C File Offset: 0x000CB55C
		public void OnChangeMap()
		{
			this.button.interactable = (Singleton<Studio.Studio>.Instance.sceneInfo.map != -1);
			if (!this.button.interactable && this.active)
			{
				this.active = false;
			}
			else
			{
				this.mapCtrl.Reflect();
			}
		}

		// Token: 0x0400230A RID: 8970
		public MapCtrl mapCtrl;

		// Token: 0x0400230B RID: 8971
		public Button button;

		// Token: 0x0400230C RID: 8972
		private Image m_Image;

		// Token: 0x0400230D RID: 8973
		private bool m_Active;
	}
}
